package com.example.utils;

import com.example.common.Constants;
import org.springframework.util.ClassUtils;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class PathUils {

    public static String getPath(){
        return System.getProperty("user.dir");
    }

    //获取路径列表文件夹
    public static String[] getSystemFileList(File file){
        return file.list();
    }


    public static String getUploadPath(String filename){
        String path=getPath();
        String dateString= DateUtils.getStringByDate(new SimpleDateFormat("yyyy-MM"),new Date());
        String uploadPath=path+ File.separator+ Constants.UPLOAD_FILE+File.separator+dateString;
        File file = new File(uploadPath);
        if(!file.exists()){
            file.mkdirs();
        }

        return uploadPath+File.separator+filename;
    }


}
